<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>用户列表</title>
  <link rel="stylesheet" type="text/css" media="screen"
        href="../static/css/bootstrap.min.css">
</head>
<body>

<div class="container">
  <ol class="breadcrumb">
    <li><a href="#">用户管理</a></li>
    <li class="active">用户添加</li>
    <li style="float:right">
      <a href="/loginOut">退出</a>&nbsp;&nbsp;&nbsp;&nbsp;</li>
  </ol>

  <!-- 主体内容开始 -->

  <!-- 表单开始 -->
  <!--			<form action="" class="form-horizontal">-->
  <!-- 待编辑区 panel开始 -->
  <div class="panel panel-info">
    <div class="panel-heading">
      <i class="fa fa-pencil"></i>&nbsp;&nbsp;添加
    </div>
    <!-- panel-body开始 -->
    <div class="panel-body">

      <div class="form-group">
        <label for="taskName" class="col-sm-3 control-label">用户名称</label>
        <div class="col-sm-5">
          <input type="text" class="form-control"
                 id="userName" name="userName" placeholder="用户名称" value="">
        </div>
      </div>

      <div class="form-group">
        <label for="password" class="col-sm-3 control-label">用户密码</label>
        <div class="col-sm-5">
          <input type="password" class="form-control"
                 id="password" name="password" placeholder="用户密码" value="">
        </div>
      </div>


    </div>
    <!-- panel-body结束 -->
    <!-- panel-footer开始 -->
    <div class="panel-footer text-right">
      <button type="button" name="returnBtn" class="btn btn-default"
              id="returnBtn" onclick="location.href='users.html'">返回</button>
      <button  name="resetBtn" id="resetBtn"
               class="btn btn-warning">重置</button>
      <button  name="submitBtn" class="btn btn-primary"
               id="submitBtn">提交</button>
    </div>
    <!-- panel-footer结束 -->
  </div>
  <!-- 待编辑区panel结束 -->
  <!--			</form>-->
  <!--表单结束 -->
</div>
</body>
</html>
<script src="../static/js/axios.min.js"></script>
<script>

  document.getElementById('submitBtn').onclick = function () {
    const userName = document.getElementById('userName').value; // 获取input的值
    const password = document.getElementById('password').value; //获取input的值
    const url = '/user/add';
    const data = {
      "username": userName,
      "password": password
    }
    axios.post(url,data).then(function (response) {
      if (response.data.code === 200) {
        alert('添加成功');
        location.href = "/users/users.html";
      }else {
        alert('添加失败');

      }

    });

  }




</script>